﻿Imports System.Data.SqlClient

Public Class DiaPhuongDAO

    Public Shared Function LoadDiaPhuong() As DataTable
        Dim cn As SqlConnection = DataProvider.Connection()
        Dim cmd = "SELECT * FROM GIONANGDIAPHUONG"
        Dim da As New SqlDataAdapter(cmd, cn)
        Dim dt As New DataTable()
        da.Fill(dt)
        cn.Close()
        Return dt
    End Function

    Public Shared Function ThemDiaPhuong(TenDiaPhuong As String, SoGioNang As Integer) As Boolean
        Dim cn As SqlConnection = DataProvider.Connection()
        Dim cmd = "insert into GIONANGDIAPHUONG(TenDiaPhuong,SoGioNang) values(N'" + TenDiaPhuong + "'," + SoGioNang.ToString() + ")"
        Try
            Dim da As New SqlCommand(cmd, cn)
            da.ExecuteNonQuery()
        Catch ex As Exception
            cn.Close()
            Return False
        End Try
        cn.Close()
        Return True
    End Function

End Class
